import React from 'react';
import {sessionManager} from '../../utils/sessionStorage';
import {Form ,Row ,Col ,Button } from 'antd';
import Grid from '../../components/table/grid';
import {injectIntl} from 'react-intl';
import axios from "axios/index";
import qs from 'qs';

const FormItem = Form.Item;
const createForm = Form.create;

class TaxOrderList extends React.Component {
    constructor(props) {
        super(props);
        this.common = this.props.intl.messages.common;
        this.state={
            params:{
                invoiceId:sessionManager.get('taxOrderList').invoiceId,
                billUserId: sessionManager.get('tax').billUserId
            },
            refresh:0
        };
        this.columns = [
            {
                title: '订单编号',
                dataIndex: 'orderId',
                key: 'orderId',
            },
            {
                title: '设备编号',
                dataIndex: 'stubId',
                key: 'stubId',
            },
            {
                title: '电站名称',
                dataIndex: 'stubGroupName',
                key: 'stubGroupName',
            },
            {
                title: '开票金额',
                dataIndex: 'orderFee',
                key: 'orderFee',
            },
            {
                title: '税点金额',
                dataIndex: 'taxPoint',
                key: 'taxPoint',
            },
            {
                title: '发票类型',
                render:(text,record)=>(
                    text.invoiceType==1?<span>普通发票</span>:<span>增值税发票</span>
                )
            },
        ]
    }

    componentDidMount() {

    }


    render() {
        const token=(JSON.parse(sessionStorage.getItem("token"))||{}).token;
        let locale=sessionManager.get('locale');
        let exportQs=`${qs.stringify(this.state.params)}&token=${token}&locale=${locale}`;
        console.log('exportQs',exportQs);
        // const {getFieldDecorator} = this.props.form;
        return (
            <div>
                <form form={this.props.form} className="SC-form">
                    <Row gutter={24} type="flex">
                        <Col>
                            <FormItem>
                                <a href={`${axios.defaults.baseURL}/api/settlement/invoice/taxOrderList/export?${exportQs}`}>
                                    <Button type="primary">{this.common.exportStatement}</Button>
                                </a>
                            </FormItem>
                        </Col>
                    </Row>
                </form>
                <Grid columns={this.columns} params={this.state.params}
                      url={'/api/settlement/invoice/taxOrderList'} refresh={this.state.refresh}/>
            </div>
        )
    }
}

TaxOrderList = createForm()(TaxOrderList);
export default injectIntl(TaxOrderList)
